struct Internals {
  /* @offset(0) */
  yFactor_ : f32,
  /* @offset(4) */
  textureOutputHeight_ : f32,
}

struct LeftOver {
  /* @offset(0) */
  diffuseMatrix : mat4x4<f32>,
  /* @offset(64) */
  biasAndScaleSM : vec3<f32>,
  /* @offset(80) */
  depthValuesSM : vec2<f32>,
  /* @offset(88) */
  softTransparentShadowSM : f32,
}

var<private> glFragCoord_ : vec4<f32>;

var<private> gl_FragCoord : vec4<f32>;

@group(1) @binding(0) var<uniform> x_75 : Internals;

@group(1) @binding(2) var diffuseSamplerTexture : texture_2d<f32>;

@group(1) @binding(3) var diffuseSamplerSampler : sampler;

var<private> vUV : vec2<f32>;

@group(1) @binding(4) var<uniform> x_129 : LeftOver;

var<private> vDepthMetricSM : f32;

var<private> glFragColor : vec4<f32>;

fn bayerDither2_vf2_(x_P : ptr<function, vec2<f32>>) -> f32 {
  let x_21 : f32 = (*(x_P)).y;
  let x_25 : f32 = (*(x_P)).x;
  return ((((2.0f * x_21) + x_25) + 1.0f) - (4.0f * floor(((((2.0f * x_21) + x_25) + 1.0f) / 4.0f))));
}

fn bayerDither8_vf2_(x_P_1 : ptr<function, vec2<f32>>) -> f32 {
  var P1 : vec2<f32>;
  var P2 : vec2<f32>;
  var P4 : vec2<f32>;
  var param : vec2<f32>;
  var param_1 : vec2<f32>;
  var param_2 : vec2<f32>;
  let x_34 : vec2<f32> = *(x_P_1);
  P1 = (x_34 - (vec2<f32>(2.0f, 2.0f) * floor((x_34 / vec2<f32>(2.0f, 2.0f)))));
  let x_39 : vec2<f32> = *(x_P_1);
  P2 = floor(((x_39 - (vec2<f32>(4.0f, 4.0f) * floor((x_39 / vec2<f32>(4.0f, 4.0f))))) * 0.5f));
  let x_46 : vec2<f32> = *(x_P_1);
  P4 = floor(((x_46 - (vec2<f32>(8.0f, 8.0f) * floor((x_46 / vec2<f32>(8.0f, 8.0f))))) * 0.25f));
  let x_53 : vec2<f32> = P1;
  param = x_53;
  let x_54 : f32 = bayerDither2_vf2_(&(param));
  let x_57 : vec2<f32> = P2;
  param_1 = x_57;
  let x_58 : f32 = bayerDither2_vf2_(&(param_1));
  let x_62 : vec2<f32> = P4;
  param_2 = x_62;
  let x_63 : f32 = bayerDither2_vf2_(&(param_2));
  return ((4.0f * ((4.0f * x_54) + x_58)) + x_63);
}

fn main_1() {
  var alphaFromAlphaTexture : f32;
  var param_3 : vec2<f32>;
  var depthSM : f32;
  let x_72 : vec4<f32> = gl_FragCoord;
  glFragCoord_ = x_72;
  let x_80 : f32 = x_75.yFactor_;
  if ((x_80 == 1.0f)) {
    let x_87 : f32 = x_75.textureOutputHeight_;
    let x_90 : f32 = glFragCoord_.y;
    glFragCoord_.y = (x_87 - x_90);
  }
  let x_106 : vec2<f32> = vUV;
  let x_107 : vec4<f32> = textureSample(diffuseSamplerTexture, diffuseSamplerSampler, x_106);
  alphaFromAlphaTexture = x_107.w;
  let x_110 : f32 = alphaFromAlphaTexture;
  if ((x_110 < 0.40000000596046447754f)) {
    discard;
  }
  let x_116 : vec4<f32> = glFragCoord_;
  param_3 = floor((vec2<f32>(x_116.x, x_116.y) - (vec2<f32>(8.0f, 8.0f) * floor((vec2<f32>(x_116.x, x_116.y) / vec2<f32>(8.0f, 8.0f))))));
  let x_122 : f32 = bayerDither8_vf2_(&(param_3));
  let x_132 : f32 = x_129.softTransparentShadowSM;
  let x_133 : f32 = alphaFromAlphaTexture;
  if (((x_122 / 64.0f) >= (x_132 * x_133))) {
    discard;
  }
  let x_142 : f32 = vDepthMetricSM;
  depthSM = x_142;
  let x_146 : f32 = x_129.biasAndScaleSM.z;
  let x_147 : f32 = depthSM;
  depthSM = clamp(exp(-(min(87.0f, (x_146 * x_147)))), 0.0f, 1.0f);
  let x_156 : f32 = depthSM;
  glFragColor = vec4<f32>(x_156, 1.0f, 1.0f, 1.0f);
  return;
}

struct main_out {
  @location(0)
  glFragColor_1 : vec4<f32>,
}

@fragment
fn main(@builtin(position) gl_FragCoord_param : vec4<f32>, @location(0) vUV_param : vec2<f32>, @location(1) vDepthMetricSM_param : f32) -> main_out {
  gl_FragCoord = gl_FragCoord_param;
  vUV = vUV_param;
  vDepthMetricSM = vDepthMetricSM_param;
  main_1();
  return main_out(glFragColor);
}